/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main.social.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author user
 */
@Entity
@Table(name = "entrys")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Entrys.findAll", query = "SELECT e FROM Entrys e"),
    @NamedQuery(name = "Entrys.findById", query = "SELECT e FROM Entrys e WHERE e.id = :id"),
    @NamedQuery(name = "Entrys.findByUuid", query = "SELECT e FROM Entrys e WHERE e.uuid = :uuid"),
    @NamedQuery(name = "Entrys.findByDate", query = "SELECT e FROM Entrys e WHERE e.date = :date")})
public class Entrys implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "uuid", length = 45)
    private String uuid;
    @Lob
    @Column(name = "content", length = 2147483647)
    private String content;
    @Basic(optional = false)
    @Column(name = "date", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;
    @Basic(optional = false)
    @Column(name = "view", nullable = false)
    private Long view;
    @OneToMany(mappedBy = "parent")
    private List<Entrys> entrysList;
    @JoinColumn(name = "parent_id", referencedColumnName = "id")
    @ManyToOne
    private Entrys parent;
    @JoinColumn(name = "EntryGroup_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Entrygroup entryGroup;
    @JoinColumn(name = "Users_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Users user;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "entrysid")
    private List<Entrylike> entrylikeList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "entrysid")
    private List<Entrytag> entrytagList;
    
    public Entrys() {
    }

    public Entrys(Long id) {
        this.id = id;
    }

    public Entrys(Long id, String link, Date date) {
        this.id = id;
        this.uuid = link;
        this.date = date;
    }
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Long getView() {
		return view;
	}

	public void setView(Long view) {
		this.view = view;
	}

	@XmlTransient
    public List<Entrys> getEntrysList() {
        return entrysList;
    }

    public void setEntrysList(List<Entrys> entrysList) {
        this.entrysList = entrysList;
    }

    public Entrys getParent() {
        return parent;
    }

    public void setParent(Entrys parent) {
        this.parent = parent;
    }

    public Entrygroup getEntryGroup() {
        return entryGroup;
    }

    public void setEntryGroup(Entrygroup entryGroup) {
        this.entryGroup = entryGroup;
    }

    public Users getUser() {
        return user;
    }

    public void setUser(Users user) {
        this.user = user;
    }

    @XmlTransient
    public List<Entrylike> getEntrylikeList() {
        return entrylikeList;
    }

    public void setEntrylikeList(List<Entrylike> entrylikeList) {
        this.entrylikeList = entrylikeList;
    }

    @XmlTransient
    public List<Entrytag> getEntrytagList() {
        return entrytagList;
    }

    public void setEntrytagList(List<Entrytag> entrytagList) {
        this.entrytagList = entrytagList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Entrys)) {
            return false;
        }
        Entrys other = (Entrys) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "main.social.entity.Entrys[ id=" + id + " ]";
    }
    
}
